package com.jiangchao.annotationmvc.business.controller;

import javax.servlet.http.HttpServletRequest;

import com.jiangchao.annotationmvc.business.form.LoginForm;
import com.jiangchao.annotationmvc.core.annotation.Controller;
import com.jiangchao.annotationmvc.core.annotation.Form;
import com.jiangchao.annotationmvc.core.annotation.Mapping;

@Controller
@Mapping("/demo")
public class DemoController {
	
	@Mapping("/login")
	@Form(path="com.jiangchao.annotationmvc.business.form.LoginForm")
	public String login(HttpServletRequest request,LoginForm loginForm) {
		String password = loginForm.getPassword();
//		给页面传递用户名
		request.setAttribute("username", loginForm.getUsername());
		if ("admin".equals(password)) {
			return "/view/success.jsp";
		}else {
			return "/view/fail.jsp";
		}
	}
	
	@Mapping("/others")
	@Form(path="com.jiangchao.annotationmvc.business.form.LoginForm")
	public String others(HttpServletRequest request,LoginForm loginForm) {
		return "/index.jsp";
	}

}
